#include "histo.h"

Histogram::Histogram(DnaSeq * tabSeq, size_t size)
{
	for(int i=0; i<size; ++i)
	{
        _data[tabSeq[i].len]++;
    }
}

void Histogram::writeData(string file)
{
	fstream out;
	out.exceptions(ifstream::failbit|ifstream::badbit);	
	try
	{
		out.open(file, ifstream::out);
		for(auto p : this->_data)
		{
			out << p.first << " " << p.second << endl;
		}
		out.close();
	}
	catch(ifstream::failure e)
	{
		cerr << "[erreur] " << e.what() << endl;
		exit(4);
	}
}

